<?php

declare(strict_types=1);

namespace app\common\model;
use think\facade\Db;

use think\Model;
use think\model\concern\SoftDelete;

class TrandingbankAllowgoods extends Model
{
    use SoftDelete;
    protected $deleteTime = "delete_time";
    // 获取列表
    public static function getList()
    {
        $where = [];
        $limit = input('get.limit');

        //按物品id查找
        if ($goodsid = input("goodsid")) {
            $where[] = ["goodsid", "like", "%" . $goodsid . "%"];
        }
        //按物品名称查找
        if ($goodname = input("goodname")) {
            $where[] = ["goodname", "like", "%" . $goodname . "%"];
        }
        //按最大数量查找
        if ($maxnum = input("maxnum")) {
            $where[] = ["maxnum", "like", "%" . $maxnum . "%"];
        }
        //按手续费查找
        if ($handingfees = input("handingfees")) {
            $where[] = ["handingfees", "like", "%" . $handingfees . "%"];
        }
        //按创建时间查找
        $start = input("get.create_time-start");
        $end = input("get.create_time-end");
        if ($start && $end) {
            $where[] = ["create_time", "between", [$start, date("Y-m-d", strtotime("$end +1 day"))]];
        }
        $list = self::order('id', 'desc')->where($where)->paginate($limit);
        return ['code' => 0, 'data' => $list->items(), 'extend' => ['count' => $list->total(), 'limit' => $limit]];
    }

    public static function checkdate($goodsid)
    {
        return Db::query("SELECT * FROM trandingbank_allowgoods WHERE  goodsid='$goodsid';")[0];
    }

    public static function shellGoods($serverid, $actorid, $goodsid, $goodsnum)
    {
        $sql="insert into ";
        return Db::query("SELECT * FROM trandingbank_allowgoods WHERE  goodsid='$goodsid';")[0];
    }
}
